package com.cloudbench.util;

public class StringUtil {
	static final String CNAME = StringUtil.class.getSimpleName();
	
	/**
	 * Check string is null or empty
	 * @param str
	 * @return
	 */
	public static boolean isEmpty(String str) {
		if(str == null || str.trim().length() ==0)
			return true;
		
		return false;
	}
	
	/**
	 * Check any string is null or empty
	 * 
	 * @param str1
	 * @param str2
	 * @return
	 */
	public static boolean isAnyEmpty(String str1, String str2) {
		if(isEmpty(str1) || isEmpty(str2))
			return true;
		
		return false;
	}

	
	/**
	 * Check all string is null or empty
	 * @param str1
	 * @param str2
	 * @return
	 */
	public static boolean isAllEmpty(String str1, String str2) {
		if(isEmpty(str1) && isEmpty(str2))
			return true;
		
		return false;
	}
	
	/**
	 * Check string is contain character 
	 * @param str
	 * @return
	 */
	public static boolean isConatinCharacter(String str) {
		if(str == null || str.trim().length() ==0)
			return false;
			
		for(int i=0; i < str.length(); i++)
			if(!Character.isDigit(str.charAt(i)))
				return false;
	
		return true;
	}
	
	/**
	 * Check string is number 
	 * @param str
	 * @return
	 */
	public static boolean isNumber(String str) {
		try {
			Long.parseLong(str);
		} catch(NumberFormatException e) {
			return false;
		}
		
		return true;
	}
	
	/**
	 * Make path
	 * 
	 * @param prefix
	 * @param postfix
	 * @return
	 */
	public static String makePath(String prefix, String postfix) {
		if(isAnyEmpty(prefix, postfix))
			return "";
		
		return prefix + " > " + postfix;
	}
	
}